/*
 * Potenziometro.h
 *
 *  Created on: 11/ago/2011
 *      Author: marcolembo
 */


#ifndef POTENZIOMETRO_H_
#define POTENZIOMETRO_H_

class Potenziometro {
public:
	typedef struct Range {
		short beginVal;
		short endVal;

		Range(short _b, short _e)
		: beginVal(_b),
		  endVal(_e){}

	} RangePot;

	Potenziometro(short _pin,
				  RangePot _range = RangePot(0, 0)
			);

	short ReadValue() const;

	void ChangeRange(RangePot _range);
	bool IsChanging(bool &isMovingToRight) const;

	virtual ~Potenziometro();

	protected:
		short m_pin;
		RangePot m_range;
		mutable short m_oldValue;
		mutable bool m_justChanged;

};

#endif /* POTENZIOMETRO_H_ */
